package com.seata.storage.feign.impl;

import com.seata.config.CommonResult;
import com.seata.storage.feign.StorageFeignClient;
import com.seata.storage.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: ${description}
 * @Author: sobey
 * @Email: sobey178@163.com
 * @Date: 2021/11/20 17:52
 */
@RestController
public class StorageFeignClientImpl implements StorageFeignClient {

    @Autowired
    private StorageService storageService;

    @Override
    @RequestMapping(MAPPING_STORAGE_DECREASE)
    public CommonResult decrease(
            @RequestParam("productId") Long productId
            , @RequestParam("count") Integer count
            , @RequestParam(value = "commit") Boolean commit
    ) {
        storageService.decrease(productId,count,commit);
        return new CommonResult("扣减库存成功！", 200);
    }
}
